<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <h1>AJAX页面</h1>
    <div id="sub"></div>
    <input type="button" id="getStudentBtn" value="获取学生数据">
    <input type="text" id="username">
    <script src="js/jquery-1.12.4.min.js"></script>
    <script>
        $("#sub").load("sub.html");

        $("#getStudentBtn").click(function(){
            $.ajax({
                url:"/students/findById",
                type:"get",
                data:{
                    id:"630c24411849ac7430bf1229"
                },
                success(res){
                    console.log(res.name);
                }
            });
        });
        $("#username").blur(function(){
            $.ajax({
                url:"/users/usernameExist",
                type:"post",
                data:{
                    username:$(this).val()
                },
                success(res){
                    console.log(res)
                }
            });
        })
    </script>
</body>
</html>